home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
-
- class ExecutionTime(object):
- '''
- Helper that can be used in with statements to have a simple
- measure of the timming of a particular block of code, e.g.
- with ExecutinTime("db flush"):
- db.flush()
- '''
-
- def __init__(self, info = ''):
- self.info = info
-
-
- def __enter__(self):
- self.now = time.time()
-
-
- def __exit__(self, type, value, stack):
- print '%s: %s' % (self.info, time.time() - self.now)
-
-
-
- def encode_for_xml(unicode_data, encoding = 'ascii'):
- ''' encode a given string for xml '''
- return unicode_data.encode(encoding, 'xmlcharrefreplace')
-
-
- def decode_xml_char_reference(s):
- """ takes a string like
- 'Search…'
- and converts it to
- 'Search...'
- """
- import re
- p = re.compile('\\&\\#x(\\d\\d\\d\\d);')
- return p.sub('\\u\\1', s).decode('unicode-escape')
-
- if __name__ == '__main__':
- s = decode_xml_char_reference('Search…')
- print s
- print type(s)
- print unicode(s)
-
-